package com.ficus.road.maintain.controller;

import com.ficus.road.maintain.client.Response.*;
import com.ficus.road.maintain.core.model.GpsLocation;
import com.ficus.road.maintain.service.XljVideoService;
import com.ficus.road.maintain.third.zh.roadgps.ZHRoadName;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 下立交视频相关
 */
@RestController
@RequiredArgsConstructor
@Slf4j
@RequestMapping("/emergency")
public class XljVideoController {

    @Autowired
    XljVideoService xljVideoService;
    @Autowired
    ZHRoadName zhRoadName;

    /**
     * 下立交视频封装
     *
     * @return
     */
    @GetMapping("/xlj/video")
    public GeiXljVideoResponse geiXljVideo(@RequestParam("XljId") String XljId) {
        String cookie = xljVideoService.LogIn();

        return xljVideoService.geiXljVideo(XljId, cookie);
    }

    /**
     * 管理单位履职

     * @return
     */
    @GetMapping("/xlj/management")
    public ManagementUnitResponse ManagementUnit() {
        ManagementUnitResponse managementUnitResponse = xljVideoService.ManagementUnit();
        return managementUnitResponse;

    }

    @PostMapping("/getroadname")
    public String getRoadName(@RequestBody GpsLocation gpsLocation){
        String poadName = zhRoadName.getRoadName(gpsLocation);
        if (poadName == null){
            return "获取道路名称失败";
        }
        return poadName;
    }

    @DeleteMapping("/xlj/test")
    public void ManagementUnittest() {
        xljVideoService.ManagementUnittest();
    }


    @GetMapping("/xlj/management/detail")
    public List<ManagementUnitDetailResponse> getManagementUnitDetail(@RequestParam("XljId") String unid) {
        return xljVideoService.getManagementUnitDetail(unid);
    }

}
